-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally output unresolved assembly conflicts #5990
Conversation
The additional parameter / output to the task look like what we need. The common targets would also need to be updated to use those when calling the ResolveAssemblyReference task. For the implementation, it should do the following. I wasn't sure but it looked like it wasn't:
Thanks! |
Does that look better? The extra information you'd want in metadata is the conflicting versions and how each was (directly or indirectly) referenced? (I wasn't sure, so I haven't added that yet.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like what we wanted, as far as I can tell.
|
||
if (OutputUnresolvedAssemblyConflicts) | ||
{ | ||
_unresolvedConflicts.Add(new TaskItem(assemblyName.Name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would include the log message with the human-readable details in the metadata for this item.
We don't currently have a use case for programmatically processing data such as conflicting version numbers, how the assembly was referenced, etc. I would say if it's straightforward to include, then go ahead and do so. But if not, then skip it for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conflicting version numbers is easy, so I included that. How it's referenced is doable, but it's a little verbose, since there could be multiple levels of dependencies (A depends on B depends on C depends on D depends on the conflicting dll). I can add it later if we decide we need it, though.
@@ -2233,6 +2235,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. | |||
<Output TaskParameter="FilesWritten" ItemName="FileWrites"/> | |||
<Output TaskParameter="DependsOnSystemRuntime" PropertyName="DependsOnSystemRuntime"/> | |||
<Output TaskParameter="DependsOnNETStandard" PropertyName="_DependsOnNETStandard"/> | |||
<Output TaskParameter="UnresolvedAssemblyConflicts" ItemName="UnresolvedAssemblyConflicts"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to use a name that's more likely to be unique. Similar to the pattern for the input property, that could be ResolveAssemblyReferenceUnresolvedAssemblyConflicts
.
@@ -990,16 +1009,36 @@ List<Exception> generalResolutionExceptions | |||
// Log the reference which lost the conflict and the dependencies and source items which caused it. | |||
LogReferenceDependenciesAndSourceItemsToStringBuilder(fusionName, conflictCandidate, logDependencies.AppendLine()); | |||
|
|||
string toOutput; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
string toOutput; | |
string toOutput = StringBuilderCache.GetStringAndRelease(logConflict); |
Both if
and else
do this as their first statement.
public ITaskItem[] UnresolvedAssemblyConflicts { | ||
get | ||
{ | ||
return _unresolvedConflicts.ToArray(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
public ITaskItem[] UnresolvedAssemblyConflicts { | |
get | |
{ | |
return _unresolvedConflicts.ToArray(); | |
} | |
} | |
public ITaskItem[] UnresolvedAssemblyConflicts => _unresolvedConflicts.ToArray(); |
{"victorVersionNumber", victor.ReferenceVersion.ToString() }, | ||
{"victimVersionNumber", conflictCandidate.ReferenceVersion.ToString() } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super-nit: Missing space after {
.
// This does an extra allocation, so only do it when necessary. | ||
if (OutputUnresolvedAssemblyConflicts) | ||
{ | ||
toOutput += '\n' + extra; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not be more structured add extra
in its own metadatum? Something like:
{ "logMessage", toOutput },
{ "logMessageDetails", extra }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of the PR
If a user sets ResolveAssemblyReferenceOutputUnresolvedAssemblyConflicts
to true, RAR will populate the output item ResolveAssemblyReferenceUnresolvedAssemblyConflicts
, which the SDK will pick up and throw the appropriate error on.
LGTM, pending 2 comments.
@@ -214,6 +215,12 @@ public bool IgnoreTargetFrameworkAttributeVersionMismatch | |||
/// </remarks> | |||
public bool FindDependenciesOfExternallyResolvedReferences { get; set; } | |||
|
|||
/// <summary> | |||
/// If true, outputs any unresolved assembly conflicts (MSB3277) in UnresolvedAssemblyConflicts | |||
/// instead of logging them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of logging them.
doesn't it do both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep! Fixed. That was a holdover from how I'd originally designed it.
@@ -3686,6 +3686,37 @@ public void ConflictGeneratesMessageReferencingAssemblyName() | |||
warningMessage.ShouldContain(ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ResolveAssemblyReference.FourSpaceIndent", ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword("ResolveAssemblyReference.ReferenceDependsOn", "D, Version=1.0.0.0, CulTUre=neutral, PublicKeyToken=aaaaaaaaaaaaaaaa", Path.Combine(s_myLibraries_V1Path, "D.dll")))); | |||
} | |||
|
|||
[Fact] | |||
public void ConflictOutputsExtraInformationOnDemand() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this a theory and test what happens when the item has the .dll
extension? @dsplaisted is there a concrete answer for including .dll
in the assembly name? Or did your comment, "possibly with .dll possibly not," refer to the fact that assemblyName.Name
may not have the extension along with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understood him to mean that the SDK can handle the output having the .dll extension or not having it—it's the same information, just presented slightly differently. Since I'm creating the item, and I went with no .dll extension, that shouldn't be an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure whether the assembly name processed by ResolveAssemblyReference would have the .dll extension on it. If it consistently does not have the extension, then I would leave it out. It's also theoretically possible to reference an .exe, I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The summary behind assemblyName.Name
:
Gets or sets the simple name of the assembly. This is usually, but not necessarily,
the file name of the manifest file of the assembly, minus its extension.
Looks like the SDK will have to account for both scenarios, unless there's a preference on how we handle it here. I'm okay with either scenario.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like MSBuild shouldn't do anything special here then (ie don't add the .dll extension).
Fixes #5934.
@dsplaisted, does this look how you expected?